<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="css/eui.css">
    <style>
        body{
            margin: 0;
            background-image: url("img/bg1.jpg");
            background-size: cover;
            text-align: center;
        }
        h1{
            font-size: 72px;
            color: #5FB878;
            margin-bottom: 0;
        }
        img{
            width: 100px;
        }
        .logo{
            width: 300px;
            height: 300px;
        }
    </style>
</head>
<body>
<div id="app">
    <h1>环绿回收</h1>
    <img src="img/bg1.jpgS" alt="">
    <el-card style="width: 600px;height: 300px;
    margin: 0 auto;background-color: rgba(255,255,255,0.3)">
        <el-container>
            <el-aside>
                <el-form style="width: 400px;margin: 30px auto" label-width="60px" >
                    <el-form-item label="手机号">
                        <el-input type="text" v-model="user.loginKey" placeholder="请输入手机名"></el-input>
                    </el-form-item>
                    <el-form-item label="验证码">
                        <input style="width: 100px;height: 40px; display: inline;float: left" v-model="user.code"
                               type="id" class="email"
                               placeholder="验证码" required/>
                        <el-button style="border: #333333;border: 1px ;color: #333333;float: left" @click="getValidCode()" class="box">获取验证码 </el-button>
                    </el-form-item>
                    <el-form-item>
                        <el-button style="position: relative;right: 35px;top: 50px" type="primary" @click="login()">登录</el-button>
                        <el-button style="position: relative;right: 35px;top: 50px" type="primary" >
                            <el-form class="resp-tab-item"><a style="text-decoration: none;color: #d9ecff" href="login.html">密码登录</a></el-form>
                        </el-button>
                    </el-form-item>
                </el-form>
            </el-aside>
            <el-main>
                <div class="head agile">
                    <div class="logo">
                        <div class="logo-top wel">
                            <img src="img/login-icon.jpg" alt="image"/>
                            <h2>欢迎</h2>
                        </div>
                        <div class="logo-bottom w3layouts">
                        </div>
                    </div>
                </div>
            </el-main>
        </el-container>
    </el-card>
</div>
</body>
<!-- import Vue before Element -->
<script src="js/vue.js"></script>
<!-- import JavaScript -->
<script src="js/eui.js"></script>
<script src="js/axios.min.js"></script>
<script>
    let v = new Vue({
        el: '#app',
        data: function() {
            return {
                user:{
                    loginKey:"",
                    code:""
                }
            }
        },
        methods:{
            login(){
                axios.post("/userLoginAccount/loginByValidCode",v.user).then(function (response) {
                    if (response.data.states===20000){
                        location.href="/adminIndex.html"; //显示管理页面
                    }else if (response.data.states===40101){
                        v.$message.error("用户名不存在!");
                    }else{
                        v.$message.error("密码错误!");
                    }
                })
            },

            getValidCode(){
                axios.get("/userValidation/sendValidSmsForLogin?phone="+v.user.loginKey).then(function (response) {
                })
            }
        }
    })
</script>
<script>
    function countDown() {
        var box = document.getElementsByClassName('box')[0];
        var time = 60;
        var timer;
        box.onclick = function () {
            clearInterval(timer);
            timer = setInterval(function () {
                if (time == 0) {
                    clearInterval(timer);
                    box.innerHTML = '点击重新获取';
                    time = 60;
                } else {
                    time--;
                    box.innerHTML = time + '秒可获取';
                }
            }, 1000)
        }
    }

    countDown()
</script>
</html>
